xen/arm: grant: Add another entry to map MFN 1:1 in dom0 p2m
authorJulien Grall <julien.grall@linaro.org>
Tue, 27 May 2014 11:11:41 +0000 (12:11 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Mon, 2 Jun 2014 15:46:41 +0000 (16:46 +0100)
commit552710b388630dfa461932940a998e120c42277d
treec05df2305dceaeca5d0db5592e0d3c9f2c43f8a8
parentd9e61eb2d2c83356f51939f2be034064e13afc8a
xen/arm: grant: Add another entry to map MFN 1:1 in dom0 p2m

Grant mappings can be used for DMA requests. Currently the dev_bus_addr returned
by the hypercall is the MFN (not the IPA). Guest expects to be able the returned
address for DMA. When the device is protected by IOMMU the request will fail.
Therefore, we have to add 1:1 mapping in the domain p2m to allow DMA request
to work.

This is valid because DOM0 has its memory mapped 1:1 and therefore we know
that RAM and devices cannot clash.

If the guest only owns protected device, the return dev_bus_addr should be an
IPA. This will allow us to remove safely the 1:1 mapping and make grant mapping
works correctly in the guest. For now, this is not addressed by this patch.

The grant mapping code does the reference counting on every MFN and will
call iommu_{map,unmap}_page when necessary. This was already handle for x86
PV guests, so we can reuse the same code path for ARM guest.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
[ ijc s/ld/d/ in both arch's gnttab_need_iommu_mapping() ]
xen/arch/arm/p2m.c
xen/common/grant_table.c
xen/drivers/passthrough/arm/smmu.c
xen/include/asm-arm/grant_table.h
xen/include/asm-arm/p2m.h
xen/include/asm-x86/grant_table.h